
package com.seekting.study;

import java.util.Vector;

public class VectorTest {

    private static Vector<String> v = new Vector<String>();

    public static void main(String[] args) {
        add(0, "a");
        add(2, "b");
        add(2, "c");
        add(1, "d");

        for (String str : v) {
            System.out.println(str);
        }
    }

    public static void add(int expectPosition, String str) {
        int size = v.size();
        int index = size;
        if (size > expectPosition) {
            index = expectPosition;
        }
        v.add(index, str);
    }
}
